objectToPairs
Creates an array of key-value pair arrays from an object.
Use Object.entries() to get an array of key-value pair arrays from the given object.
const objectToPairs = obj => Object.entries(obj);
EXAMPLES
objectToPairs({ a: 1, b: 2 }); // [ ['a', 1], ['b', 2] ]
const objectToPairs = obj =>Object.entries(obj)
將一個物件 轉換 成 鍵對值屬性的陣列
Object.entries()
Object.entries(obj) ——返回一個包含該對象所有[key, value]鍵值對的數組。
let user = {
name: "John",
age: 30
};
Object.entries(user) = [ ["name","John"], ["age",30] ]
你知道Object.entries(),但你還知道有Object.fromEntries()嗎?
原文網址:https://kknews.cc/code/x4qkx2g.html]